package com.rc.evcharger.common.type;

import com.rc.evcharger.common.annotation.ByteLength;
import com.rc.evcharger.common.utils.ToFrameUtil;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.List;

/**
 * Create by Yang on 2021/3/30
 */
public class ElectricizeInterControl extends BaseType implements DataType {

    @ByteLength(length = 1)
    String gunNum; // 1：A枪 2：B枪
    @ByteLength(length = 1)
    String startStatus; // 启动状态 2：充电开始3：停止充电
    @ByteLength(length = 17)
    String orderNum; // 00+手机号+四位流水号

    /**
     * 新增内容
     **/
    @ByteLength(length = 4)
    String userAccount; // 用户余额

    @ByteLength(length = 1)
    String beginHour1 = "00";//开始小时     0~24
    @ByteLength(length = 1)
    String beginMinute1 = "00";//开始分钟     0 或 30
    @ByteLength(length = 1)
    String endHour1 = "00";//结束小时        0~24
    @ByteLength(length = 1)
    String endMinute1 = "00";//结束分钟       0 或 30
    @ByteLength(length = 4)
    String elecPrice1 = "00 00 00 00";//电费 保留两位小数
    @ByteLength(length = 4)
    String servicePrice1 = "00 00 00 00";//服务费 保留两位小数
    @ByteLength(length = 4)
    String parkingPrice1 = "00 00 00 00";//停车费 保留两位小数

    @ByteLength(length = 1)
    String beginHour2 = "00";//开始小时     0~24
    @ByteLength(length = 1)
    String beginMinute2 = "00";//开始分钟     0 或 30
    @ByteLength(length = 1)
    String endHour2 = "00";//结束小时        0~24
    @ByteLength(length = 1)
    String endMinute2 = "00";//结束分钟       0 或 30
    @ByteLength(length = 4)
    String elecPrice2 = "00 00 00 00";//电费 保留两位小数
    @ByteLength(length = 4)
    String servicePrice2 = "00 00 00 00";//服务费 保留两位小数
    @ByteLength(length = 4)
    String parkingPrice2 = "00 00 00 00";//停车费 保留两位小数

    @ByteLength(length = 1)
    String beginHour3 = "00";//开始小时     0~24
    @ByteLength(length = 1)
    String beginMinute3 = "00";//开始分钟     0 或 30
    @ByteLength(length = 1)
    String endHour3 = "00";//结束小时        0~24
    @ByteLength(length = 1)
    String endMinute3 = "00";//结束分钟       0 或 30
    @ByteLength(length = 4)
    String elecPrice3 = "00 00 00 00";//电费 保留两位小数
    @ByteLength(length = 4)
    String servicePrice3 = "00 00 00 00";//服务费 保留两位小数
    @ByteLength(length = 4)
    String parkingPrice3 = "00 00 00 00";//停车费 保留两位小数

    @ByteLength(length = 1)
    String beginHour4 = "00";//开始小时     0~24
    @ByteLength(length = 1)
    String beginMinute4 = "00";//开始分钟     0 或 30
    @ByteLength(length = 1)
    String endHour4 = "00";//结束小时        0~24
    @ByteLength(length = 1)
    String endMinute4 = "00";//结束分钟       0 或 30
    @ByteLength(length = 4)
    String elecPrice4 = "00 00 00 00";//电费 保留两位小数
    @ByteLength(length = 4)
    String servicePrice4 = "00 00 00 00";//服务费 保留两位小数
    @ByteLength(length = 4)
    String parkingPrice4 = "00 00 00 00";//停车费 保留两位小数

    @ByteLength(length = 1)
    String beginHour5 = "00";//开始小时     0~24
    @ByteLength(length = 1)
    String beginMinute5 = "00";//开始分钟     0 或 30
    @ByteLength(length = 1)
    String endHour5 = "00";//结束小时        0~24
    @ByteLength(length = 1)
    String endMinute5 = "00";//结束分钟       0 或 30
    @ByteLength(length = 4)
    String elecPrice5 = "00 00 00 00";//电费 保留两位小数
    @ByteLength(length = 4)
    String servicePrice5 = "00 00 00 00";//服务费 保留两位小数
    @ByteLength(length = 4)
    String parkingPrice5 = "00 00 00 00";//停车费 保留两位小数

    @ByteLength(length = 1)
    String beginHour6 = "00";//开始小时     0~24
    @ByteLength(length = 1)
    String beginMinute6 = "00";//开始分钟     0 或 30
    @ByteLength(length = 1)
    String endHour6 = "00";//结束小时        0~24
    @ByteLength(length = 1)
    String endMinute6 = "00";//结束分钟       0 或 30
    @ByteLength(length = 4)
    String elecPrice6 = "00 00 00 00";//电费 保留两位小数
    @ByteLength(length = 4)
    String servicePrice6 = "00 00 00 00";//服务费 保留两位小数
    @ByteLength(length = 4)
    String parkingPrice6 = "00 00 00 00";//停车费 保留两位小数

    @ByteLength(length = 1)
    String beginHour7 = "00";//开始小时     0~24
    @ByteLength(length = 1)
    String beginMinute7 = "00";//开始分钟     0 或 30
    @ByteLength(length = 1)
    String endHour7 = "00";//结束小时        0~24
    @ByteLength(length = 1)
    String endMinute7 = "00";//结束分钟       0 或 30
    @ByteLength(length = 4)
    String elecPrice7 = "00 00 00 00";//电费 保留两位小数
    @ByteLength(length = 4)
    String servicePrice7 = "00 00 00 00";//服务费 保留两位小数
    @ByteLength(length = 4)
    String parkingPrice7 = "00 00 00 00";//停车费 保留两位小数

    @ByteLength(length = 1)
    String beginHour8 = "00";//开始小时     0~24
    @ByteLength(length = 1)
    String beginMinute8 = "00";//开始分钟     0 或 30
    @ByteLength(length = 1)
    String endHour8 = "00";//结束小时        0~24
    @ByteLength(length = 1)
    String endMinute8 = "00";//结束分钟       0 或 30
    @ByteLength(length = 4)
    String elecPrice8 = "00 00 00 00";//电费 保留两位小数
    @ByteLength(length = 4)
    String servicePrice8 = "00 00 00 00";//服务费 保留两位小数
    @ByteLength(length = 4)
    String parkingPrice8 = "00 00 00 00";//停车费 保留两位小数

    @ByteLength(length = 4)
    String obligate = "00 00 00 00";

    // 后台控制充电启停中，测量点0,1,2,3对应帧结构中的测量点号1,2,4,8，枪号0,1,2,3(珠海生产的)
    public ElectricizeInterControl(String gunNum, Integer startStatus, String orderNum, List<ElecStationPriceData> list, BigDecimal money) {
        StringBuffer sb = new StringBuffer();
        if (gunNum.length() < 2) {
            sb.append("0").append(gunNum);
            this.gunNum = sb.toString();
        } else {
            this.gunNum = gunNum;
        }

        this.startStatus = "0" + startStatus;
        this.orderNum = ToFrameUtil.orderNumToFrame(orderNum);
        if (money.compareTo(new BigDecimal("1000")) == 1) {
            money = new BigDecimal("1000");
        }
        this.userAccount = ToFrameUtil.accountToFrame(money);
        //对分时段、电价进行赋值
        try {
            for (int i = 0; i < list.size(); i++) {

                //反射机制得到变量域
                Field beginHourField = this.getClass().getDeclaredField("beginHour" + (i + 1));
                Field beginMinuteField = this.getClass().getDeclaredField("beginMinute" + (i + 1));
                Field endHourField = this.getClass().getDeclaredField("endHour" + (i + 1));
                Field endMinuteField = this.getClass().getDeclaredField("endMinute" + (i + 1));
                Field elecPriceField = this.getClass().getDeclaredField("elecPrice" + (i + 1));
                Field servicePriceField = this.getClass().getDeclaredField("servicePrice" + (i + 1));
                try {
                    beginHourField.setAccessible(true);
                    beginHourField.set(this, list.get(i).getBeginHour());

                    beginMinuteField.setAccessible(true);
                    beginMinuteField.set(this, list.get(i).getBeginMinute());

                    endHourField.setAccessible(true);
                    endHourField.set(this, list.get(i).getEndHour());

                    endMinuteField.setAccessible(true);
                    endMinuteField.set(this, list.get(i).getEndMinute());

                    elecPriceField.setAccessible(true);
                    elecPriceField.set(this, list.get(i).getElecPrice());

                    servicePriceField.setAccessible(true);
                    servicePriceField.set(this, list.get(i).getServicePrice());
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }

            }
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
    }

    public String getGunNum() {
        return gunNum;
    }

    public void setGunNum(String gunNum) {
        this.gunNum = gunNum;
    }

    public String getStartStatus() {
        return startStatus;
    }

    public void setStartStatus(String startStatus) {
        this.startStatus = startStatus;
    }

    public String getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(String orderNum) {
        this.orderNum = orderNum;
    }

    public String getUserAccount() {
        return userAccount;
    }

    public void setUserAccount(String userAccount) {
        this.userAccount = userAccount;
    }

    public String getBeginHour1() {
        return beginHour1;
    }

    public void setBeginHour1(String beginHour1) {
        this.beginHour1 = beginHour1;
    }

    public String getBeginMinute1() {
        return beginMinute1;
    }

    public void setBeginMinute1(String beginMinute1) {
        this.beginMinute1 = beginMinute1;
    }

    public String getEndHour1() {
        return endHour1;
    }

    public void setEndHour1(String endHour1) {
        this.endHour1 = endHour1;
    }

    public String getEndMinute1() {
        return endMinute1;
    }

    public void setEndMinute1(String endMinute1) {
        this.endMinute1 = endMinute1;
    }

    public String getElecPrice1() {
        return elecPrice1;
    }

    public void setElecPrice1(String elecPrice1) {
        this.elecPrice1 = elecPrice1;
    }

    public String getServicePrice1() {
        return servicePrice1;
    }

    public void setServicePrice1(String servicePrice1) {
        this.servicePrice1 = servicePrice1;
    }

    public String getParkingPrice1() {
        return parkingPrice1;
    }

    public void setParkingPrice1(String parkingPrice1) {
        this.parkingPrice1 = parkingPrice1;
    }

    public String getBeginHour2() {
        return beginHour2;
    }

    public void setBeginHour2(String beginHour2) {
        this.beginHour2 = beginHour2;
    }

    public String getBeginMinute2() {
        return beginMinute2;
    }

    public void setBeginMinute2(String beginMinute2) {
        this.beginMinute2 = beginMinute2;
    }

    public String getEndHour2() {
        return endHour2;
    }

    public void setEndHour2(String endHour2) {
        this.endHour2 = endHour2;
    }

    public String getEndMinute2() {
        return endMinute2;
    }

    public void setEndMinute2(String endMinute2) {
        this.endMinute2 = endMinute2;
    }

    public String getElecPrice2() {
        return elecPrice2;
    }

    public void setElecPrice2(String elecPrice2) {
        this.elecPrice2 = elecPrice2;
    }

    public String getServicePrice2() {
        return servicePrice2;
    }

    public void setServicePrice2(String servicePrice2) {
        this.servicePrice2 = servicePrice2;
    }

    public String getParkingPrice2() {
        return parkingPrice2;
    }

    public void setParkingPrice2(String parkingPrice2) {
        this.parkingPrice2 = parkingPrice2;
    }

    public String getBeginHour3() {
        return beginHour3;
    }

    public void setBeginHour3(String beginHour3) {
        this.beginHour3 = beginHour3;
    }

    public String getBeginMinute3() {
        return beginMinute3;
    }

    public void setBeginMinute3(String beginMinute3) {
        this.beginMinute3 = beginMinute3;
    }

    public String getEndHour3() {
        return endHour3;
    }

    public void setEndHour3(String endHour3) {
        this.endHour3 = endHour3;
    }

    public String getEndMinute3() {
        return endMinute3;
    }

    public void setEndMinute3(String endMinute3) {
        this.endMinute3 = endMinute3;
    }

    public String getElecPrice3() {
        return elecPrice3;
    }

    public void setElecPrice3(String elecPrice3) {
        this.elecPrice3 = elecPrice3;
    }

    public String getServicePrice3() {
        return servicePrice3;
    }

    public void setServicePrice3(String servicePrice3) {
        this.servicePrice3 = servicePrice3;
    }

    public String getParkingPrice3() {
        return parkingPrice3;
    }

    public void setParkingPrice3(String parkingPrice3) {
        this.parkingPrice3 = parkingPrice3;
    }

    public String getBeginHour4() {
        return beginHour4;
    }

    public void setBeginHour4(String beginHour4) {
        this.beginHour4 = beginHour4;
    }

    public String getBeginMinute4() {
        return beginMinute4;
    }

    public void setBeginMinute4(String beginMinute4) {
        this.beginMinute4 = beginMinute4;
    }

    public String getEndHour4() {
        return endHour4;
    }

    public void setEndHour4(String endHour4) {
        this.endHour4 = endHour4;
    }

    public String getEndMinute4() {
        return endMinute4;
    }

    public void setEndMinute4(String endMinute4) {
        this.endMinute4 = endMinute4;
    }

    public String getElecPrice4() {
        return elecPrice4;
    }

    public void setElecPrice4(String elecPrice4) {
        this.elecPrice4 = elecPrice4;
    }

    public String getServicePrice4() {
        return servicePrice4;
    }

    public void setServicePrice4(String servicePrice4) {
        this.servicePrice4 = servicePrice4;
    }

    public String getParkingPrice4() {
        return parkingPrice4;
    }

    public void setParkingPrice4(String parkingPrice4) {
        this.parkingPrice4 = parkingPrice4;
    }

    public String getBeginHour5() {
        return beginHour5;
    }

    public void setBeginHour5(String beginHour5) {
        this.beginHour5 = beginHour5;
    }

    public String getBeginMinute5() {
        return beginMinute5;
    }

    public void setBeginMinute5(String beginMinute5) {
        this.beginMinute5 = beginMinute5;
    }

    public String getEndHour5() {
        return endHour5;
    }

    public void setEndHour5(String endHour5) {
        this.endHour5 = endHour5;
    }

    public String getEndMinute5() {
        return endMinute5;
    }

    public void setEndMinute5(String endMinute5) {
        this.endMinute5 = endMinute5;
    }

    public String getElecPrice5() {
        return elecPrice5;
    }

    public void setElecPrice5(String elecPrice5) {
        this.elecPrice5 = elecPrice5;
    }

    public String getServicePrice5() {
        return servicePrice5;
    }

    public void setServicePrice5(String servicePrice5) {
        this.servicePrice5 = servicePrice5;
    }

    public String getParkingPrice5() {
        return parkingPrice5;
    }

    public void setParkingPrice5(String parkingPrice5) {
        this.parkingPrice5 = parkingPrice5;
    }

    public String getBeginHour6() {
        return beginHour6;
    }

    public void setBeginHour6(String beginHour6) {
        this.beginHour6 = beginHour6;
    }

    public String getBeginMinute6() {
        return beginMinute6;
    }

    public void setBeginMinute6(String beginMinute6) {
        this.beginMinute6 = beginMinute6;
    }

    public String getEndHour6() {
        return endHour6;
    }

    public void setEndHour6(String endHour6) {
        this.endHour6 = endHour6;
    }

    public String getEndMinute6() {
        return endMinute6;
    }

    public void setEndMinute6(String endMinute6) {
        this.endMinute6 = endMinute6;
    }

    public String getElecPrice6() {
        return elecPrice6;
    }

    public void setElecPrice6(String elecPrice6) {
        this.elecPrice6 = elecPrice6;
    }

    public String getServicePrice6() {
        return servicePrice6;
    }

    public void setServicePrice6(String servicePrice6) {
        this.servicePrice6 = servicePrice6;
    }

    public String getParkingPrice6() {
        return parkingPrice6;
    }

    public void setParkingPrice6(String parkingPrice6) {
        this.parkingPrice6 = parkingPrice6;
    }

    public String getBeginHour7() {
        return beginHour7;
    }

    public void setBeginHour7(String beginHour7) {
        this.beginHour7 = beginHour7;
    }

    public String getBeginMinute7() {
        return beginMinute7;
    }

    public void setBeginMinute7(String beginMinute7) {
        this.beginMinute7 = beginMinute7;
    }

    public String getEndHour7() {
        return endHour7;
    }

    public void setEndHour7(String endHour7) {
        this.endHour7 = endHour7;
    }

    public String getEndMinute7() {
        return endMinute7;
    }

    public void setEndMinute7(String endMinute7) {
        this.endMinute7 = endMinute7;
    }

    public String getElecPrice7() {
        return elecPrice7;
    }

    public void setElecPrice7(String elecPrice7) {
        this.elecPrice7 = elecPrice7;
    }

    public String getServicePrice7() {
        return servicePrice7;
    }

    public void setServicePrice7(String servicePrice7) {
        this.servicePrice7 = servicePrice7;
    }

    public String getParkingPrice7() {
        return parkingPrice7;
    }

    public void setParkingPrice7(String parkingPrice7) {
        this.parkingPrice7 = parkingPrice7;
    }

    public String getBeginHour8() {
        return beginHour8;
    }

    public void setBeginHour8(String beginHour8) {
        this.beginHour8 = beginHour8;
    }

    public String getBeginMinute8() {
        return beginMinute8;
    }

    public void setBeginMinute8(String beginMinute8) {
        this.beginMinute8 = beginMinute8;
    }

    public String getEndHour8() {
        return endHour8;
    }

    public void setEndHour8(String endHour8) {
        this.endHour8 = endHour8;
    }

    public String getEndMinute8() {
        return endMinute8;
    }

    public void setEndMinute8(String endMinute8) {
        this.endMinute8 = endMinute8;
    }

    public String getElecPrice8() {
        return elecPrice8;
    }

    public void setElecPrice8(String elecPrice8) {
        this.elecPrice8 = elecPrice8;
    }

    public String getServicePrice8() {
        return servicePrice8;
    }

    public void setServicePrice8(String servicePrice8) {
        this.servicePrice8 = servicePrice8;
    }

    public String getParkingPrice8() {
        return parkingPrice8;
    }

    public void setParkingPrice8(String parkingPrice8) {
        this.parkingPrice8 = parkingPrice8;
    }

    public String getObligate() {
        return obligate;
    }

    public void setObligate(String obligate) {
        this.obligate = obligate;
    }

    @Override
    public boolean customField(Field field, StringBuffer sb) {
        return false;
    }
}
